<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>信息管理</el-breadcrumb-item>
      <el-breadcrumb-item>邮件列表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
      <el-table :data="emailList" style="width: 100%">
        <el-table-column prop="sender" label="寄件人" ></el-table-column>
        <el-table-column prop="caption" label="标题"></el-table-column>
        <el-table-column prop="content" label="内容"></el-table-column>
        <el-table-column label="日期" >
          <template slot-scope="pro">
            <span>
             {{pro.row.createTime}}
            </span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pageNum"
        :page-sizes="[5, 10,50]"
        :page-size="queryInfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-card>
  </div>
</template>
<style lang="less" scoped>
</style>
<script>
import {getEmailList} from '@/utils/SupervisorApi'
export default {
  data() {
    return {
      emailList: [],
      queryInfo: {
        query: "",
        // 当前页数
        pageNum: 1,
        // 每页显示多少数据
        pageSize: 10,
      },
      total: 0,
    };
  },
  created(){
    this.getEmailList()
  },
  methods: {
    async getEmailList() {
      const { data: res } = await getEmailList(
          this.queryInfo,
      );
      if (res.meta.status !== 200) {
        return this.$message.error("获取商品列表失败！");
      }
      console.log(res)
      this.emailList = res.data.list;
      console.log(this.emailList)
      this.total = res.data.total;
    },
    handleSizeChange(newSize) {
      console.log(newSize);
      this.queryInfo.pageSize = newSize;
      this.getEmailList();
    },
    // 监听 页码值 改变事件
    handleCurrentChange(newSize) {
      // console.log(newSize)
      this.queryInfo.pageNum = newSize;
      this.getEmailList();
    },
  },
};
</script>